﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MicroBenchmarks.InternalField
{
    /// <summary>
    /// A class that demonstrates the challenges where a desired object state is created 
    /// by a desired combination of methods. NO SIDEAFFECTS happen during the manipulations of
    /// this method
    /// </summary>
    public class InternalFields
    {
        private int member1, member2, member3;
        private bool localState;
        public bool InternalState 
        {
            get{
                return localState;
            }        
        }

        private void SetLocalState()
        {
            if (member1 == 5 && member2 == 3 && member3 > 2)
                localState = true;
        }

        public int Member1
        {
            get
            {
                return member1;
            }
        }

        public int Member2
        {
            get
            {
                return member2;
            }
        }

        public int Member3
        {
            get
            {
                return member3;
            }
        }


        public void IncrM1()
        {
            member1++;
            SetLocalState();
        }

        public void IncrM2AndDecrM1()
        {
            member2++;
            member1--;
            SetLocalState();
        }

        public void IncrM3AndDecrM1()
        {
            member3++;
            member1--;
            SetLocalState();
        }   
    }
}
